﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDebug>

#include "Tcp/tcpsocket.h"
#include"SSH/tm_sshconnectwgt.h"
#include "mygraphicsview.h"
#include "dlgwgt/dlgcarpara.h"
#include "dlgwgt/dlglaserpara.h"
#include "dlgwgt/dlgvisionpara.h"
#include "dlgwgt/dlgimupara.h"
#include "dlgwgt/dlgreporterror.h"
#include "common.h"
#include "UI/wgtpara.h"
#include "directedgraph.h"
#include "Tcp/maptcpsocket.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void loadUI();
signals:
    void sig_ConnectNavi(QString ip,int port);
    void sig_NaviSendData(QString type,QString data = "");
    void sig_Loger(QString logger);
    void sig_getCreatorMapData(QString data);
public slots:
    void slot_UpDataRemoteMapList(QString Type,QString data);//SSh指令状态反馈
    void slot_MyGraphicsView_Data(QString Type,QString data);
    void slot_MyGraphicsView_LineData(QString Type,QVariantMap dataMap);//当前选择的路线和点位参数数据
    void slot_TcpRevData(QString type,QStringList dataList);


    void contextMenuEvent(QContextMenuEvent *event);

    void showRightmenu(QPoint point);//重复任务右击菜单栏

    void slot_loadMapFiles(QString filePath);//加载地图文件

    void slot_ParaData(QString text,QString data);//设置路线参数

    void slot_ShowMessageDlg(QString Titie,QString text,int ms);//message提示框
private slots:

    void on_actionOpenMap_triggered();

    void on_actionSaveMap_triggered();

    void on_horizontalSlider_Point_sliderMoved(int position);

    void on_actionConnect_triggered();

    void on_lineEdit_Angle_returnPressed();

    void on_lineEdit_PointName_returnPressed();

    void on_btn_MapUpdate_clicked();

    void on_btn_Push_clicked();

    void on_btn_pull_clicked();

    void on_btn_PointDel_clicked();

    void on_btn_LineDel_clicked();

    void on_btn_Sendnavi_clicked();

    void on_comboBox_Direct_activated(int index);

    void on_btn_Sendnavi_XY_clicked();

    void on_checkBox_linear_clicked(bool checked);

    void on_actionrobotFocus_triggered(bool checked);

    void on_actionCreateMap_triggered();

    void on_lineEdit_MapName_returnPressed();

    void on_action_NewLine_triggered(bool checked);

    void on_action_VirtureWall_triggered(bool checked);

    void on_action_Eraser_triggered(bool checked);

    void on_action_Select_triggered(bool checked);

    void on_actionChangeMap_triggered();

    void on_action_pullMap_triggered();

    void on_action_addpoint_triggered();

    void on_action_Location_triggered(bool checked);

    void on_action_Robot_triggered(bool checked);

    void on_lineEdit_PointX_returnPressed();

    void on_lineEdit_PointY_returnPressed();

    void on_btn_CarPara_clicked();

    void on_btn_LaserPara_clicked();

    void on_btn_showError_clicked();

    void on_btn_vision_clicked();

    void on_lineEdit_localPath_returnPressed();

    void on_pushButton_clicked();

    void on_btn_Task_clicked();

    void on_action_pause_triggered(bool checked);

    void on_action_cancel_triggered();

    void on_action_mapEdit_triggered(bool checked);

    void on_radioButton_StartEnd_clicked(bool checked);

    void on_radioButton_endStart_clicked(bool checked);

    void on_pushButton_pullCarPara_clicked();

    void on_pushButton_2_clicked();

    void on_lineEdit_pointFind_returnPressed();

public:
    DirectedGraph *m_DirectedGraph = nullptr;
    QMap<QString,WgtPara*> m_LiniPataMap;
    MyGraphicsView *m_MapGraphicsView = nullptr;
    TM_SSHConnectWGT *m_TMSSHConnectWGT = nullptr;

    TcpSocket *m_TcpSocket = nullptr;
    mapTcpSocket *m_TcpSocket_GetCreatMap = nullptr;
    QThread m_TcpThread;
    QThread m_TcpThread_GetCreatMap;

    QThread m_LoggerThread;

    QLabel *m_Connect_Label = nullptr;

    QLabel *m_JiTing_Label = nullptr;

    QLabel *m_Battery_Label = nullptr;
    QLabel *m_RobotViewCen = nullptr;

    DlgCarPara *m_DlgCarPara = nullptr;
    DlgLaserPara *m_DlgLaserPara = nullptr;
    DlgVisionPara *m_DlgVisionPara = nullptr;
    DlgIMUPara *m_DlgIMUPara = nullptr;
    DlgReportError *m_DlgReportError = nullptr;

protected:
    bool eventFilter(QObject *obj, QEvent *event);
private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
